package org.neuedu.chapter07_0624.mydemo01;

public class StudentDaoImpl implements StudentDao {
    @Override
    public Student getInfos(String name) {
        Student[] students = DataBaseOfStudent.students;
        for (Student student : students) {
            if (name.equals(student.getName())) {
                return student;
            }
        }
        return null;
    }

    @Override
    public Student updateInfos(Student stu) {
        Student[] students = DataBaseOfStudent.students;
        for (Student student : students) {
            if (stu.getName().equals(student.getName())) {
                student.setAge(stu.getAge());
                return student;
            }
        }
        return null;
    }

    @Override
    public Student updateInfos2(String name, int age) {
        Student[] students = DataBaseOfStudent.students;
        for (Student student : students) {
            if (name.equals(student.getName())) {
                student.setAge(age);
                return student;
            }
        }
        return null;
    }
}
